<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
	require('connect_sql.php');
	require('function.php');
	$query="select * from usertable;";
	$result=mysql_query($query)or die("用户名访问错误:".mysql_error());
	session_start();

	if($_POST['username']&&$_POST['passwd'])
	{
		while($row=mysql_fetch_array($result)){
			if($row['userid']==$_POST["username"]){
				$password=md5($_POST['passwd']);	
				if($row['password']==$password){
					$_SESSION['userid']=$_POST['username'];
					turnpage("../index.php");
				}	
				else notpw();	
				break;
			}
		}
		if(!$row) notid();
	}
	else echo "请输入账号和密码！";
	
	
	

	function notid(){
		echo "用户名错误!";
	}

	function notpw(){
		echo "密码错误!";
	}
?>